package com.xxh.initial.system.service.impl;

import com.xxh.initial.system.entity.SysRole;
import com.xxh.initial.system.entity.SysUserRole;
import com.xxh.initial.system.mapper.SysRoleMapper;
import com.xxh.initial.system.service.ISysRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxh.initial.system.service.ISysUserRoleService;
import com.xxh.initial.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xyf
 * @since 2025-04-02
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
    SysRoleMapper sysRoleMapper;

    @Autowired
    ISysUserRoleService sysUserRoleService;

    @Override
    public void testRoleAdd(SysRole sysRole) {
        //将此角色保存到角色表
        this.save(sysRole);
        //将新增的角色添加到角色用户中间表(为超级管理员添加对应关系)
        SysUserRole sysUserRole = new SysUserRole();
        sysUserRole.setRoleId(sysRole.getRoleId());
        sysUserRole.setUserId(1);
        sysUserRoleService.save(sysUserRole);
    }
}
